//
//  MyVoiceCell.m
//  79环信
//
//  Created by 刘恒槟 on 15/8/5.
//  Copyright (c) 2015年 刘恒槟. All rights reserved.
//

#import "MyVoiceCell.h"
#import "ToolView.h"
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
@interface MyVoiceCell ()

@property (strong, nonatomic) IBOutlet UIButton *voice;
@property (nonatomic ,strong) NSURL * voiceUrl;
@property (nonatomic ,strong) PlayVoiceBlock playVoiceBlockHandle;
@property(nonatomic,strong)AVAudioPlayer *audioPlayer;//播放录音文件
@end

@implementation MyVoiceCell

- (void)awakeFromNib {
    // Initialization code
}
- (IBAction)play:(id)sender {
    
    NSError *error;
    self.audioPlayer=[[AVAudioPlayer alloc]initWithContentsOfURL:self.voiceUrl error:&error];
    if (error) {
        NSLog(@"error==%@",error.localizedDescription);
    }
//    ToolView *toolView = [[ToolView alloc]init];
    self.audioPlayer.volume=9;
    //准备播放;
    [self.audioPlayer prepareToPlay];
    //播放
    [self.audioPlayer play];
    
}
-(void)setTapPlayVoiceBlockHandle:(PlayVoiceBlock)playVoiceHandle
{
    self.playVoiceBlockHandle = playVoiceHandle;
}

-(void)setCellInfoWithNSDictionary:(NSDictionary *)dic{
    
    
    
    self.dic = dic;
    self.voiceUrl = dic[@"msg"];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
